home *** CD-ROM | disk | FTP | other *** search
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/Changelog,v
- retrieving revision 1.17
- diff -c -r1.17 Changelog
- *** 1.17 1992/08/14 15:18:43
- --- Changelog 1992/12/28 08:11:47
- ***************
- *** 293,295 ****
- --- 293,300 ----
- add target for ident.o
-
- ---------------------------- Patchlevel 19 ------------------------------
- +
- + sqrt.c:: Michal Jaegermann
- + major hacks. see the comments at the top.
- +
- + ---------------------------- Patchlevel 20 ------------------------------
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/PatchLev.h,v
- retrieving revision 1.16
- diff -c -r1.16 PatchLev.h
- *** 1.16 1992/08/14 15:20:26
- --- PatchLev.h 1992/12/28 08:11:48
- ***************
- *** 1,4 ****
- ! #define PatchLevel "19"
-
- /*
- *
- --- 1,4 ----
- ! #define PatchLevel "20"
-
- /*
- *
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/math.h,v
- retrieving revision 1.14
- diff -c -r1.14 math.h
- *** 1.14 1992/08/14 15:18:43
- --- math.h 1992/12/28 08:11:51
- ***************
- *** 46,51 ****
- --- 46,57 ----
- extern "C" {
- #endif
-
- + #ifdef __TURBOC__
- +
- + #include <tcmath.h>
- +
- + #else
- +
- #ifndef __STRICT_ANSI__
- /*
- * Create the type "COMPLEX". This is an obvious extension that I
- ***************
- *** 76,94 ****
- double retval; /* val to return */
- };
-
- ! #define M_LN2 0.69314718055994530942
- ! #define M_PI 3.14159265358979323846
- ! #define M_SQRT2 1.41421356237309504880
- ! #define M_E 2.7182818284590452354
- ! #define M_LOG2E 1.4426950408889634074
- ! #define M_LOG10E 0.43429448190325182765
- ! #define M_LN10 2.30258509299404568402
- ! #define M_PI_2 1.57079632679489661923
- ! #define M_PI_4 0.78539816339744830962
- ! #define M_1_PI 0.31830988618379067154
- ! #define M_2_PI 0.63661977236758134308
- ! #define M_2_SQRTPI 1.12837916709551257390
- ! #define M_SQRT1_2 0.70710678118654752440
-
- #endif /* __STRICT_ANSI__ */
-
- --- 82,100 ----
- double retval; /* val to return */
- };
-
- ! #define M_LN2 0.69314718055994530942
- ! #define M_PI 3.14159265358979323846
- ! #define M_SQRT2 1.41421356237309504880
- ! #define M_E 2.7182818284590452354
- ! #define M_LOG2E 1.4426950408889634074
- ! #define M_LOG10E 0.43429448190325182765
- ! #define M_LN10 2.30258509299404568402
- ! #define M_PI_2 1.57079632679489661923
- ! #define M_PI_4 0.78539816339744830962
- ! #define M_1_PI 0.31830988618379067154
- ! #define M_2_PI 0.63661977236758134308
- ! #define M_2_SQRTPI 1.12837916709551257390
- ! #define M_SQRT1_2 0.70710678118654752440
-
- #endif /* __STRICT_ANSI__ */
-
- ***************
- *** 183,188 ****
- --- 189,196 ----
- __EXTERN double ldexp __PROTO((double, int));
- __EXTERN double frexp __PROTO((double, int *));
- #endif /* !_M68881 */
- +
- + #endif /* __TURBOC__ */
-
- #ifdef __cplusplus
- }
- ===================================================================
- RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/sqrt.c,v
- retrieving revision 1.8
- diff -c -r1.8 sqrt.c
- *** 1.8 1992/02/03 20:19:23
- --- sqrt.c 1992/12/28 08:11:53
- ***************
- *** 17,23 ****
- ************************************************************************
- */
-
- !
- /*
- * FUNCTION
- *
- --- 17,23 ----
- ************************************************************************
- */
-
- !
- /*
- * FUNCTION
- *
- ***************
- *** 116,141 ****
- * machine I tried.
- *
- */
- !
- /*
- * MODIFICATIONS
- *
- ! * This routine modified to use polynomial, instead of rational,
- ! * approximation with coefficients
- ! *
- ! * P0 0.22906994529e+00
- ! * P1 0.13006690496e+01
- ! * P2 -0.90932104982e+00
- ! * P3 0.50104207633e+00
- ! * P4 -0.12146838249e+00
- ! *
- ! * as given by Hart (op. cit.) in SQRT 0132. This approximation
- ! * gives around 5 digits correct. Two applications of Heron's
- ! * approximation will give more then practically achievable
- ! * 13-15 decimal digits. Multiplications by powers of 2 are
- ! * replaced by explicit calls to ldexp.
- *
- ! * Michal Jaegermann, 24 October 1990
- */
-
- #if !defined (__M68881__) && !defined (sfp004)
- --- 116,146 ----
- * machine I tried.
- *
- */
- !
- /*
- * MODIFICATIONS
- *
- ! * Function sqrt(x) is initially approximated on an
- ! * interval [0.5..2.0] by a quadratic polynomial with
- ! * the following coefficients
- ! *
- ! * P0 0.3608580479718948e+00
- ! * P1 0.7477707028388739e+00
- ! * P2 -0.1105464728191369e+00
- ! *
- ! * These coefficients were computed with a help of Maple
- ! * symbolic algebra system. Longer approximation interval
- ! * is used in order to avoid multiplication by SQRT2
- ! * constant in case of odd exponents (this idea comes from
- ! * Olaf Flebbe, flebbe@tat.physik.uni-tuebingen.de). With
- ! * 64 bit IEEE representation three Heron's iterations are
- ! * good enough to satisfy essential requirements of Paranoia
- ! * test suite. An absolute error after three iterations is
- ! * below 2e-19 over the whole range (below 5e-10 after two).
- ! * Multiplications by powers of 2 are performed by explicit
- ! * calls to ldexp.
- *
- ! * Michal Jaegermann, 21 October 1992
- */
-
- #if !defined (__M68881__) && !defined (sfp004)
- ***************
- *** 144,164 ****
- #include <math.h>
- #include "pml.h"
-
- ! #ifdef OLD
- ! #define P0 0.594604482 /* Approximation coeff */
- ! #define P1 2.54164041 /* Approximation coeff */
- ! #define Q0 2.13725758 /* Approximation coeff */
- ! #define Q1 1.0 /* Approximation coeff */
- !
- ! #define ITERATIONS 3 /* Number of iterations */
- !
- ! #endif
- !
- ! #define P0 0.22906994529e+00 /* Hart SQRT 0132 */
- ! #define P1 0.13006690496e+01
- ! #define P2 -0.90932104982e+00
- ! #define P3 0.50104207633e+00
- ! #define P4 -0.12146838249e+00
-
- static char funcname[] = "sqrt";
-
- --- 149,157 ----
- #include <math.h>
- #include "pml.h"
-
- ! #define P0 0.3608580479718948e+00
- ! #define P1 0.7477707028388739e+00
- ! #define P2 -0.1105464728191369e+00
-
- static char funcname[] = "sqrt";
-
- ***************
- *** 165,183 ****
- double sqrt (x)
- double x;
- {
- - #ifdef OLD
- int k;
- - register int bugfix;
- - register int kmod2;
- - register int count;
- - int exponent;
- - double y;
- - #else
- - int k;
- - #endif
- double m;
- double u;
- struct exception xcpt;
-
- if (x == 0.0) {
- xcpt.retval = 0.0;
- --- 158,168 ----
- double sqrt (x)
- double x;
- {
- int k;
- double m;
- double u;
- struct exception xcpt;
- + register double (*dfunc)(double, int) = ldexp;
-
- if (x == 0.0) {
- xcpt.retval = 0.0;
- ***************
- *** 192,222 ****
- }
- } else {
- m = frexp (x, &k);
- - #ifdef OLD
- - u = (P0 + (P1 * m)) / (Q0 + (Q1 * m));
- - for (count = 0, y = u; count < ITERATIONS; count++) {
- - y = 0.5 * (y + (m / y));
- - }
- - if ((kmod2 = (k % 2)) < 0) {
- - y /= SQRT2;
- - } else if (kmod2 > 0) {
- - y *= SQRT2;
- - }
- - bugfix = 2;
- - xcpt.retval = ldexp (y, k/bugfix);
- - #else
- - u = (((P4 * m + P3) * m + P2) * m + P1) * m + P0;
- - u = ldexp((u + (m / u)), -1); /* Heron's iteration */
- - u += m / u; /* and a part of the second one */
- if (k & 1) {
- ! u *= SQRT2;
- }
- /*
- * here we rely on the fact that -3/2 and (-3 >> 1)
- ! * do give different results
- */
- ! xcpt.retval = ldexp (u, (k >> 1) - 1);
- ! #endif
- }
- return (xcpt.retval);
- }
- --- 177,206 ----
- }
- } else {
- m = frexp (x, &k);
- if (k & 1) {
- ! m = dfunc(m, 1);
- ! /*
- ! * multiply by 2 if our exponent was odd;
- ! * odd k is now too big by 1 but (k >> 1) will take
- ! * care of that
- ! */
- }
- + u = (P2 * m + P1) * m + P0; /* the first guess */
- +
- + u = dfunc((u + (m / u)), -1); /* Heron's iteration */
- + #ifndef __SOZOBON__
- + /*
- + * with current floating point representation used
- + * by Sozobon C we are already below achievable precision
- + */
- + u = dfunc((u + (m / u)), -1); /* one more */
- + #endif /* __SOZOBON__ */
- /*
- * here we rely on the fact that -3/2 and (-3 >> 1)
- ! * do give different results;
- ! * the last iteration and adjust final exponent properly
- */
- ! xcpt.retval = dfunc (u + (m / u), (k >> 1) - 1);
- }
- return (xcpt.retval);
- }
-